﻿var status = 0;
var minLevel = 175;
var maxLevel = 250;
var maxMegnice1 = 1;
var objDate=new Date();
var day=objDate.getDay();
var maxinum = 10;

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
   	var dayly = ""; 
if (cm.getPlayer().isGM()){
			　dayly = "#r#e\r\n#L1#GM!#k#n"; 
}
   if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 0 && status == 0) {
            cm.dispose();
            return;
        }
        if (mode == 1) status++;
        else status--;
        if (status == 0) {

            cm.sendSimple("#e剩餘名額:"+(maxinum-cm.getEventLogForDay("每日定量簽到"))+"位\r\n#e要進行簽到嗎??\r\n#b#L0#簽到"+dayly+"");
        } else if (status == 1) {
            if (selection == 0) {

                if (cm.getBossLog("每日定量簽到" +day+ "") < 1 && cm.getEventLogForDay("每日定量簽到") <= maxinum) { // 
                    cm.setBossLog("每日定量簽到" +day+ "");
                    cm.setEventLogForDay("每日定量簽到");
                    cm.gainItem(4031312, 20);
                    cm.gainItem(5062000, 50);//奇幻方塊
                    cm.sendOk("以領取每日獎勵。");
cm.worldSpouseMessage(0x07, "[限量簽到] : 玩家【"+cm.getChar().getName()+"】以搶先簽到,剩下"+(maxinum-cm.getEventLogForDay("每日定量簽到"))+"名額");

                    cm.dispose();
                        
                } else{ // 不是隊長
                    cm.sendOk("今天以領取過或名額不足。");
                    cm.dispose();
                 } 
                  } else if (selection == 1) {
            cm.resetEventLogForDay("每日定量簽到");
            cm.sendOk("重置成功！");
        }
    }
}
}